package com.jifeng.api.crud.controller;

import com.jifeng.api.annotation.AccessLimitAnnotation;
import com.jifeng.api.crud.entity.TerminalEntity;
import com.jifeng.api.crud.service.TerminalService;
import com.jifeng.api.utils.R;
import com.jifeng.api.vo.ReqRentVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;


/**
 * @author jifeng
 * @email 1593140625@qq.com
 * @date 2020-09-05 09:24:03
 */
@RestController
@RequestMapping("crud/terminal")
public class TerminalController {
    @Autowired
    private TerminalService terminalService;

    /**
     * 远程开仓
     */
    @PostMapping("/pc/remote/open")
    public R remoteOpen(@RequestParam Map<String,Object> params){
        R rs=terminalService.remoteOpen(params);
        return rs;
    }

    /**
     * 远程禁用
     */
    @PostMapping("/pc/remote/disable")
    public R remoteDisable(@RequestParam Map<String,Object> params){
        R rs=terminalService.remoteDisable(params);
        return rs;
    }

    /**
     * 获得机柜位置信息
     */
    @GetMapping("/pc/map/list")
    public R getLocationInfo(@RequestParam Map<String,Object> params){
        R rs=terminalService.getLocationInfo(params);
        return rs;
    }

    /**
     * 判断是否租赁成功
     */
    @PostMapping("/rent/finish")
    @AccessLimitAnnotation
    public R isRentFinish(@RequestBody ReqRentVo params) {
        R rs = terminalService.isRentFinish(params);
        return rs;
    }

    /**
     * 判断设备是否等待付款
     */
    @AccessLimitAnnotation
    @PostMapping("/rent/wxpay/wait")
    public R waitPay(@RequestBody ReqRentVo params) {
        R rs = terminalService.waitPay(params);
        return rs;
    }

    /**
     * 更新指定机柜租用设备结果
     */
    @PostMapping("/rent/result/update")
    public R updateRentResult(@RequestBody ReqRentVo params) {
        R rs = terminalService.updateRentResult(params);
        return rs;
    }

    /**
     * 更新指定机柜是否有可租用设备查询结果
     */
    @PostMapping("/is_rent/result/update")
    public R updateIsRentResult(@RequestBody ReqRentVo params) {
        R rs = terminalService.updateIsRentResult(params);
        return rs;
    }

    /**
     * 判断指定机柜是否有可租用设备
     */
    @GetMapping("/is_rent")
    public R isRent(@RequestParam Map<String, Object> params) {
        R rs = terminalService.isRent(params);

        return rs;
    }

    /**
     * 查询单个机柜信息
     */
    @GetMapping("/pc/get")
    public R getOneTerminal(@RequestParam Map<String, Object> params) {
        R rs = terminalService.getOneTerminal(params);

        return rs;
    }

    /**
     * 增加机柜
     */
    @PostMapping("/pc/add")
    public R insertTerminal(@RequestBody TerminalEntity terminal) {
       R rs= terminalService.insertTerminal(terminal);

        return rs;
    }

    /**
     * 修改机柜状态为空闲
     */
    @PostMapping("/update")
    public R updateTerminalStatus(@RequestBody Map<String, Object> params) {
        R rs = terminalService.updateTerminalStatus(params);

        return rs;
    }

    /**
     * 修改机柜数据
     */
    @PostMapping("/updateAll")
    public R updateTerminalAll(@RequestBody TerminalEntity terminalEntity) {
        R rs = terminalService.updateTerminalAll(terminalEntity);

        return rs;
    }

    /**
     * 删除机柜
     */
    @PostMapping("/pc/del")
    public R delTerminal(@RequestBody Map<String, Object> params) {
        R rs= terminalService.deleteTerminal(params);

        return rs;
    }
    /**
     * 修改机柜
     */
    @PostMapping("/pc/upd")
    public R updTerminal(@RequestBody TerminalEntity terminalEntity) {
        R rs= terminalService.updateTerminal(terminalEntity);

        return rs;
    }

}
